﻿using Silverlight.Training.Client.Common.ServiceReference.EventArgs;
using Silverlight.Training.Client.Common.ServiceReference.Contracts;

namespace SilverLight.Training.Models
{
    public class DepartmentDetailsModel : ModelBase
    {
        public event System.EventHandler<CollectionFeedbackCompletedEventArgs<Department>> GetDepartmentCollectionCompleted;
        public event System.EventHandler<SingleFeedbackCompletedEventArgs<Department>> GetSingleDepartmentCompleted;

        public DepartmentDetailsModel() : base()
        {
            client.GetDepartmentCollectionCompleted += client_GetDepartmentCollectionCompleted;
            client.GetSingleDepartmentCompleted += client_GetSingleDepartmentCompleted;
        }

        public void GetDepartmentCollectionAsync()
        {
            client.GetDepartmentCollectionAsync();
        }

        public void GetSingleDepartmentAsync(int deptID)
        {
            client.GetSingleDepartmentAsync(deptID);
        }

        void client_GetSingleDepartmentCompleted(object sender, SingleFeedbackCompletedEventArgs<Department> e)
        {
            if (GetSingleDepartmentCompleted != null)
            {
                GetSingleDepartmentCompleted(sender, e);
            }
        }

        void client_GetDepartmentCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Department> e)
        {
            if (GetDepartmentCollectionCompleted != null)
            {
                GetDepartmentCollectionCompleted(sender, e);
            }
        }
    }
}
